clear all

use recognition


// -------------------------------------------------------------------------------------------------
// Table 3
// -------------------------------------------------------------------------------------------------

reghdfe istop i.demo##i.super_demo adjbasicpay timewithgroup numawds_ind ///
			timeingov paychangerate if ishighawduniq, ///
				absorb(allo_id gradenum edlev occnum agerangenum)

reghdfe isbottom i.demo##i.super_demo adjbasicpay timewithgroup numawds_ind ///
			timeingov paychangerate if islowawduniq,	///
				absorb(allo_id gradenum edlev occnum agerangenum)



// -------------------------------------------------------------------------------------------------
// Table 4
// -------------------------------------------------------------------------------------------------
reghdfe	istop i.samedutystat##i.demo##i.super_demo ///
			adjbasicpay timewithgroup ///
			numawds_ind timeingov paychangerate if ishighawduniq, ///
					absorb(allo_id gradenum edlev occnum agerangenum)  



reghdfe	isbottom i.samedutystat##i.demo##i.super_demo ///
			adjbasicpay timewithgroup ///
			numawds_ind timeingov paychangerate if islowawduniq, ///
					absorb(allo_id gradenum edlev occnum agerangenum)




// -------------------------------------------------------------------------------------------------
// Table 5
// -------------------------------------------------------------------------------------------------
reghdfe	istop i.samedutystat##i.demo##i.super_demo ///
			adjbasicpay timewithgroup ///
			numawds_ind timeingov paychangerate if ishighawduniq, ///
					absorb(allo_id gradenum edlev occnum agerangenum)  
		 
*within-group effect of co-location (relative to non-co-location) when manager is white man, varying employee race/sex	
mat wm = J(4,5,.)
forvalues i = 1/4 {
lincom 1.samedutystat + 1.samedutystat#`i'.demo + 1.samedutystat#1.super_demo ///
		 + 1.samedutystat#`i'.demo#1.super_demo	 
mat wm[`i',1] = r(estimate)
mat wm[`i',2] = r(lb)
mat wm[`i',3] = r(ub)
mat wm[`i',4] = r(se)
mat wm[`i',5] = r(p)
}
mat rownames wm = wm ww mc wc
mat colnames wm = b lb ub se p

*within-group effect of co-location (relative to non-co-location) when manager is white woman, varying employee race/sex	
mat ww = J(4,5,.)
forvalues i = 1/4 {
lincom 1.samedutystat + 1.samedutystat#`i'.demo + 1.samedutystat#2.super_demo ///
		 + 1.samedutystat#`i'.demo#2.super_demo	 
mat ww[`i',1] = r(estimate)
mat ww[`i',2] = r(lb)
mat ww[`i',3] = r(ub)
mat ww[`i',4] = r(se)
mat ww[`i',5] = r(p)
}
mat rownames ww = wm ww mc wc
mat colnames ww = b lb ub se p
		 
*within-group effect of co-location (relative to non-co-location) when manager is man of color, varying employee race/sex	
mat mc = J(4,5,.)
forvalues i = 1/4 {
lincom 1.samedutystat + 1.samedutystat#`i'.demo + 1.samedutystat#3.super_demo ///
		 + 1.samedutystat#`i'.demo#3.super_demo	 
mat mc[`i',1] = r(estimate)
mat mc[`i',2] = r(lb)
mat mc[`i',3] = r(ub)
mat mc[`i',4] = r(se)
mat mc[`i',5] = r(p)
}		 
mat rownames mc = wm ww mc wc
mat colnames mc = b lb ub se p		 
		 
*within-group effect of co-location (relative to non-co-location) when manager is woman of color, varying employee race/sex	
mat wc = J(4,5,.)
forvalues i = 1/4 {
lincom 1.samedutystat + 1.samedutystat#`i'.demo + 1.samedutystat#4.super_demo ///
		 + 1.samedutystat#`i'.demo#4.super_demo	 
mat wc[`i',1] = r(estimate)
mat wc[`i',2] = r(lb)
mat wc[`i',3] = r(ub)
mat wc[`i',4] = r(se)
mat wc[`i',5] = r(p)
}		 
mat rownames wc = wm ww mc wc
mat colnames wc = b lb ub se p	

matselrc wm wmtab, row() col(1 4 5)
matselrc ww wwtab, row() col(1 4 5)
matselrc mc mctab, row() col(1 4 5)
matselrc wc wctab, row() col(1 4 5)

mat samedutytab = wmtab,wwtab,mctab,wctab


frmttable, statmat(samedutytab) substat(2) ///
		ctitles("","Supervisor","","",""\ ///
		"Team member","White man","White woman","Man of color","Woman of color") ///
		rtitles("White man"\ ///
				""\ ///
				""\ ///
				"White woman"\ ///
				""\ ///
				""\ ///
				"Man of color"\ ///
				""\ ///
				""\ ///
				"Woman of color"\ ///
				""\ ///
				"") ///
		sdec(3,3,3,3 \ ///
			3,3,3,3 \ ///
			3,3,3,3) ///
		nocenter fragment tex ///
		replace  	




// -------------------------------------------------------------------------------------------------
// Table 6
// -------------------------------------------------------------------------------------------------
reghdfe	isbottom i.samedutystat##i.demo##i.super_demo ///
			adjbasicpay timewithgroup ///
				numawds_ind timeingov paychangerate if islowawduniq, ///
					absorb(allo_id gradenum edlev occnum agerangenum)

		 
*within-group effect of co-location (relative to non-co-location) when manager is white man, varying employee race/sex	
mat wm = J(4,5,.)
forvalues i = 1/4 {
lincom 1.samedutystat + 1.samedutystat#`i'.demo + 1.samedutystat#1.super_demo ///
		 + 1.samedutystat#`i'.demo#1.super_demo	 
mat wm[`i',1] = r(estimate)
mat wm[`i',2] = r(lb)
mat wm[`i',3] = r(ub)
mat wm[`i',4] = r(se)
mat wm[`i',5] = r(p)
}
mat rownames wm = wm ww mc wc
mat colnames wm = b lb ub se p

*within-group effect of co-location (relative to non-co-location) when manager is white woman, varying employee race/sex	
mat ww = J(4,5,.)
forvalues i = 1/4 {
lincom 1.samedutystat + 1.samedutystat#`i'.demo + 1.samedutystat#2.super_demo ///
		 + 1.samedutystat#`i'.demo#2.super_demo	 
mat ww[`i',1] = r(estimate)
mat ww[`i',2] = r(lb)
mat ww[`i',3] = r(ub)
mat ww[`i',4] = r(se)
mat ww[`i',5] = r(p)
}
mat rownames ww = wm ww mc wc
mat colnames ww = b lb ub se p
		 
*within-group effect of co-location (relative to non-co-location) when manager is man of color, varying employee race/sex	
mat mc = J(4,5,.)
forvalues i = 1/4 {
lincom 1.samedutystat + 1.samedutystat#`i'.demo + 1.samedutystat#3.super_demo ///
		 + 1.samedutystat#`i'.demo#3.super_demo	 
mat mc[`i',1] = r(estimate)
mat mc[`i',2] = r(lb)
mat mc[`i',3] = r(ub)
mat mc[`i',4] = r(se)
mat mc[`i',5] = r(p)
}		 
mat rownames mc = wm ww mc wc
mat colnames mc = b lb ub se p		 
		 
*within-group effect of co-location (relative to non-co-location) when manager is woman of color, varying employee race/sex	
mat wc = J(4,5,.)
forvalues i = 1/4 {
lincom 1.samedutystat + 1.samedutystat#`i'.demo + 1.samedutystat#4.super_demo ///
		 + 1.samedutystat#`i'.demo#4.super_demo	 
mat wc[`i',1] = r(estimate)
mat wc[`i',2] = r(lb)
mat wc[`i',3] = r(ub)
mat wc[`i',4] = r(se)
mat wc[`i',5] = r(p)
}		 
mat rownames wc = wm ww mc wc
mat colnames wc = b lb ub se p	

matselrc wm wmtab, row() col(1 4 5)
matselrc ww wwtab, row() col(1 4 5)
matselrc mc mctab, row() col(1 4 5)
matselrc wc wctab, row() col(1 4 5)

mat samedutytab = wmtab,wwtab,mctab,wctab


frmttable, statmat(samedutytab) substat(2) ///
		ctitles("","Supervisor","","",""\ ///
		"Team member","White man","White woman","Man of color","Woman of color") ///
		rtitles("White man"\ ///
				""\ ///
				""\ ///
				"White woman"\ ///
				""\ ///
				""\ ///
				"Man of color"\ ///
				""\ ///
				""\ ///
				"Woman of color"\ ///
				""\ ///
				"") ///
		sdec(2,2,2,2 \ ///
			2,2,2,2 \ ///
			3,3,3,3) ///
		nocenter fragment tex ///
		replace  		















// -------------------------------------------------------------------------------------------------
// Table 7
// -------------------------------------------------------------------------------------------------
reghdfe	istop i.samedutystat##i.demo##i.super_demo ///
			adjbasicpay timewithgroup numawds_ind ///
			timeingov paychangerate if ishighawduniq, ///
					absorb(allo_id gradenum edlev occnum agerangenum)  


mat congsameloc = J(3,5,.)
mat congdiffloc = J(3,5,.)
mat congloctest = J(3,5,.)
***white woman demographic congruence	
*within-group effect of being a white woman (relative to being a white man) when co-located *and* manager is white woman			
lincom 2.demo + 1.samedutystat#2.demo + 2.demo#2.super_demo + 1.samedutystat#2.demo#2.super_demo	
mat congsameloc[1,1] = r(estimate)
mat congsameloc[1,2] = r(lb)
mat congsameloc[1,3] = r(ub)
mat congsameloc[1,4] = r(se)
mat congsameloc[1,5] = r(p)	
*within-group effect of being a white woman (relative to being a white man) when *not* co-located *and* manager is white woman
lincom 2.demo + 0.samedutystat#2.demo + 2.demo#2.super_demo + 0.samedutystat#2.demo#2.super_demo
mat congdiffloc[1,1] = r(estimate)
mat congdiffloc[1,2] = r(lb)
mat congdiffloc[1,3] = r(ub)
mat congdiffloc[1,4] = r(se)
mat congdiffloc[1,5] = r(p)				
* difference in above two effects 
lincom 	(2.demo + 1.samedutystat#2.demo + 2.demo#2.super_demo + 1.samedutystat#2.demo#2.super_demo) ///
		- ///
		(2.demo + 0.samedutystat#2.demo + 2.demo#2.super_demo + 0.samedutystat#2.demo#2.super_demo)
mat congloctest[1,1] = r(estimate)
mat congloctest[1,2] = r(lb)
mat congloctest[1,3] = r(ub)
mat congloctest[1,4] = r(se)
mat congloctest[1,5] = r(p)			
		
		
***man of color demographic congruence		
*within-group effect of being a nonwhite man (relative to being a white man) when co-located *and* manager is man of color			
lincom 3.demo + 1.samedutystat#3.demo + 3.demo#3.super_demo + 1.samedutystat#3.demo#3.super_demo
mat congsameloc[2,1] = r(estimate)
mat congsameloc[2,2] = r(lb)
mat congsameloc[2,3] = r(ub)
mat congsameloc[2,4] = r(se)
mat congsameloc[2,5] = r(p)				
*within-group effect of being a nonwhite man (relative to being a white man) when *not* co-located *and* manager is man of color
lincom 3.demo + 0.samedutystat#3.demo + 3.demo#3.super_demo + 0.samedutystat#3.demo#3.super_demo
mat congdiffloc[2,1] = r(estimate)
mat congdiffloc[2,2] = r(lb)
mat congdiffloc[2,3] = r(ub)
mat congdiffloc[2,4] = r(se)
mat congdiffloc[2,5] = r(p)						
* difference in above two effects 
lincom 	(3.demo + 1.samedutystat#3.demo + 3.demo#3.super_demo + 1.samedutystat#3.demo#3.super_demo) ///
		- ///
		(3.demo + 0.samedutystat#3.demo + 3.demo#3.super_demo + 0.samedutystat#3.demo#3.super_demo)	
mat congloctest[2,1] = r(estimate)
mat congloctest[2,2] = r(lb)
mat congloctest[2,3] = r(ub)
mat congloctest[2,4] = r(se)
mat congloctest[2,5] = r(p)				
		

***woman of color demographic congruence		
*within-group effect of being a nonwhite woman (relative to being a white man) when co-located *and* manager is woman of color			
lincom 4.demo + 1.samedutystat#4.demo + 4.demo#4.super_demo + 1.samedutystat#4.demo#4.super_demo
mat congsameloc[3,1] = r(estimate)
mat congsameloc[3,2] = r(lb)
mat congsameloc[3,3] = r(ub)	
mat congsameloc[3,4] = r(se)
mat congsameloc[3,5] = r(p)				
*within-group effect of being a nonwhite woman (relative to being a white man) when *not* co-located *and* manager is woman of color
lincom 4.demo + 0.samedutystat#4.demo + 4.demo#4.super_demo + 0.samedutystat#4.demo#4.super_demo
mat congdiffloc[3,1] = r(estimate)
mat congdiffloc[3,2] = r(lb)
mat congdiffloc[3,3] = r(ub)
mat congdiffloc[3,4] = r(se)
mat congdiffloc[3,5] = r(p)						
* difference in above two effects 
lincom 	(4.demo + 1.samedutystat#4.demo + 4.demo#4.super_demo + 1.samedutystat#4.demo#4.super_demo) ///
		- ///
		(4.demo + 0.samedutystat#4.demo + 4.demo#4.super_demo + 0.samedutystat#4.demo#4.super_demo)
mat congloctest[3,1] = r(estimate)
mat congloctest[3,2] = r(lb)
mat congloctest[3,3] = r(ub)
mat congloctest[3,4] = r(se)
mat congloctest[3,5] = r(p)	
		
		
matselrc congsameloc congsameloctab, row() col(1 4 5)
matselrc congdiffloc congdiffloctab, row() col(1 4 5)
matselrc congloctest congloctestt, row() col(1 4 5)

mat congall = congsameloctab,congdiffloctab,congloctestt


frmttable, statmat(congall) substat(2) ///
		ctitles("","Co-located","Not co-located","Difference in effect size") ///
		rtitles("White woman"\ ///
				""\ ///
				""\ ///
				"Man of color"\ ///
				""\ ///
				""\ ///
				"Woman of color"\ ///
				""\ ///
				"") ///
		sdec(3,3,3 \ ///
			3,3,3 \ ///
			3,3,3) ///
		nocenter fragment tex ///
		replace  	 







// -------------------------------------------------------------------------------------------------
// Table 8
// -------------------------------------------------------------------------------------------------
reghdfe	isbottom i.samedutystat##i.demo##i.super_demo ///
			adjbasicpay timewithgroup numawds_ind ///
			timeingov paychangerate if islowawduniq, ///
					absorb(allo_id gradenum edlev occnum agerangenum)


mat congsameloc = J(3,5,.)
mat congdiffloc = J(3,5,.)
mat congloctest = J(3,5,.)
***white woman demographic congruence	
*within-group effect of being a white woman (relative to being a white man) when co-located *and* manager is white woman			
lincom 2.demo + 1.samedutystat#2.demo + 2.demo#2.super_demo + 1.samedutystat#2.demo#2.super_demo	
mat congsameloc[1,1] = r(estimate)
mat congsameloc[1,2] = r(lb)
mat congsameloc[1,3] = r(ub)
mat congsameloc[1,4] = r(se)
mat congsameloc[1,5] = r(p)	
*within-group effect of being a white woman (relative to being a white man) when *not* co-located *and* manager is white woman
lincom 2.demo + 0.samedutystat#2.demo + 2.demo#2.super_demo + 0.samedutystat#2.demo#2.super_demo
mat congdiffloc[1,1] = r(estimate)
mat congdiffloc[1,2] = r(lb)
mat congdiffloc[1,3] = r(ub)
mat congdiffloc[1,4] = r(se)
mat congdiffloc[1,5] = r(p)				
* difference in above two effects 
lincom 	(2.demo + 1.samedutystat#2.demo + 2.demo#2.super_demo + 1.samedutystat#2.demo#2.super_demo) ///
		- ///
		(2.demo + 0.samedutystat#2.demo + 2.demo#2.super_demo + 0.samedutystat#2.demo#2.super_demo)
mat congloctest[1,1] = r(estimate)
mat congloctest[1,2] = r(lb)
mat congloctest[1,3] = r(ub)
mat congloctest[1,4] = r(se)
mat congloctest[1,5] = r(p)			
		
		
***man of color demographic congruence		
*within-group effect of being a nonwhite man (relative to being a white man) when co-located *and* manager is man of color			
lincom 3.demo + 1.samedutystat#3.demo + 3.demo#3.super_demo + 1.samedutystat#3.demo#3.super_demo
mat congsameloc[2,1] = r(estimate)
mat congsameloc[2,2] = r(lb)
mat congsameloc[2,3] = r(ub)
mat congsameloc[2,4] = r(se)
mat congsameloc[2,5] = r(p)				
*within-group effect of being a nonwhite man (relative to being a white man) when *not* co-located *and* manager is man of color
lincom 3.demo + 0.samedutystat#3.demo + 3.demo#3.super_demo + 0.samedutystat#3.demo#3.super_demo
mat congdiffloc[2,1] = r(estimate)
mat congdiffloc[2,2] = r(lb)
mat congdiffloc[2,3] = r(ub)
mat congdiffloc[2,4] = r(se)
mat congdiffloc[2,5] = r(p)						
* difference in above two effects 
lincom 	(3.demo + 1.samedutystat#3.demo + 3.demo#3.super_demo + 1.samedutystat#3.demo#3.super_demo) ///
		- ///
		(3.demo + 0.samedutystat#3.demo + 3.demo#3.super_demo + 0.samedutystat#3.demo#3.super_demo)	
mat congloctest[2,1] = r(estimate)
mat congloctest[2,2] = r(lb)
mat congloctest[2,3] = r(ub)
mat congloctest[2,4] = r(se)
mat congloctest[2,5] = r(p)				
		

***woman of color demographic congruence		
*within-group effect of being a nonwhite woman (relative to being a white man) when co-located *and* manager is woman of color			
lincom 4.demo + 1.samedutystat#4.demo + 4.demo#4.super_demo + 1.samedutystat#4.demo#4.super_demo
mat congsameloc[3,1] = r(estimate)
mat congsameloc[3,2] = r(lb)
mat congsameloc[3,3] = r(ub)	
mat congsameloc[3,4] = r(se)
mat congsameloc[3,5] = r(p)				
*within-group effect of being a nonwhite woman (relative to being a white man) when *not* co-located *and* manager is woman of color
lincom 4.demo + 0.samedutystat#4.demo + 4.demo#4.super_demo + 0.samedutystat#4.demo#4.super_demo
mat congdiffloc[3,1] = r(estimate)
mat congdiffloc[3,2] = r(lb)
mat congdiffloc[3,3] = r(ub)
mat congdiffloc[3,4] = r(se)
mat congdiffloc[3,5] = r(p)						
* difference in above two effects 
lincom 	(4.demo + 1.samedutystat#4.demo + 4.demo#4.super_demo + 1.samedutystat#4.demo#4.super_demo) ///
		- ///
		(4.demo + 0.samedutystat#4.demo + 4.demo#4.super_demo + 0.samedutystat#4.demo#4.super_demo)
mat congloctest[3,1] = r(estimate)
mat congloctest[3,2] = r(lb)
mat congloctest[3,3] = r(ub)
mat congloctest[3,4] = r(se)
mat congloctest[3,5] = r(p)	
		
		
matselrc congsameloc congsameloctab, row() col(1 4 5)
matselrc congdiffloc congdiffloctab, row() col(1 4 5)
matselrc congloctest congloctestt, row() col(1 4 5)

mat congall = congsameloctab,congdiffloctab,congloctestt


frmttable, statmat(congall) substat(2) ///
		ctitles("","Co-located","Not co-located","Difference in effect size") ///
		rtitles("White woman"\ ///
				""\ ///
				""\ ///
				"Man of color"\ ///
				""\ ///
				""\ ///
				"Woman of color"\ ///
				""\ ///
				"") ///
		sdec(3,3,3 \ ///
			3,3,3 \ ///
			3,3,3) ///
		nocenter fragment tex ///
		replace  	 





